using System;
using System.Runtime.Serialization;

namespace Beaker.OpenCube.Resources
{
	[DataContract]
	public class TextureFrameMetadata
		: IEquatable<TextureFrameMetadata>
	{
		public TextureFrameMetadata( int index, int time )
		{
			Index = index;
			Time = time;
		}

		public TextureFrameMetadata( int index )
		{
			Index = index;
		}

		public TextureFrameMetadata()
		{
		}

		[DataMember( Name = "index" )]
		public int Index { get; set; }

		[DataMember( Name = "time" )]
		public int? Time { get; set; }

		public override int GetHashCode()
		{
			unchecked
			{
				return ( Index * 397 ) ^ Time.GetHashCode();
			}
		}

		public static bool operator ==( TextureFrameMetadata left, TextureFrameMetadata right )
		{
			return Equals( left, right );
		}

		public static bool operator !=( TextureFrameMetadata left, TextureFrameMetadata right )
		{
			return !Equals( left, right );
		}


		public override bool Equals( object obj )
		{
			if( ReferenceEquals( null, obj ) ) return false;
			if( ReferenceEquals( this, obj ) ) return true;
			if( obj.GetType() != this.GetType() ) return false;
			return Equals( (TextureFrameMetadata)obj );
		}

		public bool Equals( TextureFrameMetadata other )
		{
			if( ReferenceEquals( null, other ) ) return false;
			if( ReferenceEquals( this, other ) ) return true;
			return Index == other.Index && Time == other.Time;
		}

	}
}